



//
//  NPostionSearchResultVC.m
//  nncloud
//
//  Created by macfai on 2018/12/26.
//  Copyright © 2018 macfai. All rights reserved.
//

#import "NPostionSearchResultVC.h"
#import "NMineCell.h"
#import "NSerchZhiweiViewController.h"
#import "NZhaopinCell.h"
#import "NQIyeRecruitDetailVC.h"
#import "NQiuzhiModel.h"

@interface NPostionSearchResultVC ()<UITableViewDataSource,UITableViewDelegate,STPickerSingleDelegate>

@property(nonatomic,strong)UITableView *tableView;

@property(nonatomic,strong)NSMutableArray *dataArray;

@property(nonatomic,strong)NSArray *titleArray;

@property(nonatomic,strong)NSArray *pickerArray;

@property (nonatomic,assign)NSInteger index;

@property (nonatomic,strong)STPickerSingle *picker;

@end

@implementation NPostionSearchResultVC

#define cellIdentifier @"zhaopin"
#define SectionHeaderHeight  10.f

-(UITableView *)tableView{
    
    if (!_tableView) {
        
        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0 , 0, ScreenWidth , ScreenHeight - 64) style:UITableViewStyleGrouped];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.rowHeight = 115.f;
        _tableView.backgroundColor = kBackgroundColor;
        [_tableView registerNib:[UINib nibWithNibName:@"NZhaopinCell" bundle:nil] forCellReuseIdentifier:cellIdentifier];
        _tableView.showsVerticalScrollIndicator = NO;
        //        _tableView.tableFooterView = [UIView new];
        
    }
    return _tableView;
}

- (void)viewDidLoad {
    
    [super viewDidLoad];
    self.view.backgroundColor = kWhiteColor;
    self.dataArray = [NSMutableArray array];
    self.index = 0;
    [self.navigationItem setItemWithTitle:@"搜索结果" textColor:kNavigationTitleColor fontSize:18 itemType:center];
    [self.view addSubview:self.tableView];
    [self loadData];
    // Do any additional setup after loading the view.
}

- (void)loadData{
    [SVProgressHUD show];
    [[NNRCNetRequest manager]getWithUrl:kZhaopinListUrl params:self.dict?:@{} success:^(id result) {
        YYLog(@"%@",result);
        WeakStament(ws);
        if ([[result objectForKey:@"code"] integerValue] == 0) {
            NSArray *arr = result[@"page"][@"records"];
            YYLog(@"%@",arr);
            
            if (arr.count==0) {
                [AFToast showText:@"查询结果为空"];
            }
            
            for (NSDictionary *dict in arr) {
                NQiuzhiModel *model = [NQiuzhiModel mj_objectWithKeyValues:dict];
                [ws.dataArray addObject:model];
            }
            [ws.tableView reloadData];
            [SVProgressHUD dismiss];
        }else{
            [AFToast showText:result[@"msg"]];
            [SVProgressHUD dismiss];
        }
        
    } failure:^(id failure) {
        
    }];
}



- (void)tapAction:(UIButton *)btn
{
    
}

#pragma mark - datasource

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return  self.dataArray.count;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    NQiuzhiModel*model = self.dataArray[indexPath.section];
    NZhaopinCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath];
    cell.zhaopinModel = model;
    return cell;
}



#pragma mark - delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    NQiuzhiModel*model = self.dataArray[indexPath.section];
    NQIyeRecruitDetailVC *detail = [NQIyeRecruitDetailVC new];
    detail.zhaopinId = model.empInfoId;
    [self.navigationController pushViewController:detail animated:YES];
}


#pragma mark - section head
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return SectionHeaderHeight;//如果设置section的header高度，不设置footer高度，footer默认等于header高度
}



- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, SectionHeaderHeight)];
    view.backgroundColor = kBackgroundColor;
    return view;
}

#pragma mark - section foot
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0;
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    return nil;
}



@end
